package components.brush {
	import UIUtils.uif_color;
	import UIUtils.uif_util;
	
	import flash.display.BitmapData;
	import flash.display.Shader;
	import flash.filters.ShaderFilter;
	import flash.geom.Point;
	import flash.utils.ByteArray;

	public class c_colorSelectEraser extends c_spotBrush {
		[Embed(source="shaders/findColorBrush.pbj", mimeType="application/octet-stream")]
		private static var IShaderClass: Class;
		private var _shader			: Shader;
		private var _shaderFilter	: ShaderFilter;
		
		public function c_colorSelectEraser() {
			super();
			_shader 		= createShader();
			_shaderFilter 	= new ShaderFilter(_shader);
		}
		
		protected function createShader(): Shader {
			var sd: ByteArray = new IShaderClass();
			return new Shader(sd);
		}
		
		override public function beginSession(drawLayer		: BitmapData, point: Point): void {
			var pColor: Array = uif_color.uintToRGBA(drawLayer.getPixel32(point.x, point.y));
			if (pColor[3] > 0)
				_shader.data.findColor.value	= [pColor[1] / 0xFF, pColor[2] / 0xFF, pColor[3] / 0xFF, 1];
			_shader.data.radius.value[0]	= radius;
			_shader.data.variation.value[0] = 0.2;
			super.beginSession(drawLayer, point);
			//_shader.data.color.value		= [setColor[1], setColor[2], setColor[3], 1]*/				
//			_shader.data.src.input 			= copyLayer;
		}
		
		override public function drawStamp(drawLayer	: BitmapData, point: Point, stampScale	: Point=null): void {
			if (_shaderFilter) {
				_shader.data.position.value[0] 	= point.x;
				_shader.data.position.value[1] 	= point.y;
				_tmpLayer.applyFilter(_tmpLayer, _tmpLayer.rect, uif_util.NULLPOINT, _shaderFilter);
			}
		}
		
		override protected function copyToLayerSessionStep(): void {
		}
		
	}
}